﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ComponentModel.DataAnnotations;
using MobileSales.Model.Localization;
using MobileSales.Model.Util;

namespace MobileSales.Model.Documents
{
    [DataContract]
    public class DocumentType
    {
        [DataMember]
        public int Id { get; set; }
        [DataMember]
        [Display(Name = "Name", ResourceType = typeof(ModelStrings))]
        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
        public string Name { get; set; }
        [DataMember]
        [Display(Name = "Prefix", ResourceType = typeof(ModelStrings))]
        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
        public string Prefix { get; set; }

        [DataMember(Name = "Direction")]
        private string _direction { get; set; }

        [Display(Name = "Direction", ResourceType = typeof(ModelStrings))]
        public DocumentDirection Direction
        {
            get
            {
                if (_direction == null) _direction = DocumentDirection.Incoming.ToString();
                return (DocumentDirection)Enum.Parse(typeof(DocumentDirection), _direction);

            }
            set
            {
                _direction = value.ToString();
            }
        }

        [DataMember]
        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
        [Display(Name = "NextNo", ResourceType = typeof(ModelStrings))]
        [RegularExpression(RegExp.IntegerRegexp, ErrorMessageResourceName = "InvalidInteger", ErrorMessageResourceType = typeof(ValidationStrings))]
        public int NextNo { get; set; }
    }
}
